﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ taglib prefix="d" uri="/WEB-INF/resource.tld" %>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>
  
  <div class="container main-content">

    <div class="panel panel-default x-panel x-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/individual-rounds">课程管理</a></li>
          <li class="active">课件管理</li>
          <li class="no-before pull-right" style="min-width: 65px;">
            <a onclick="window.history.back();"><i class="glyphicon glyphicon-arrow-left"></i>&nbsp;&nbsp;返回</a>
          </li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 x-panel-layout-right">

          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire" title="分组模板详情"></i>&nbsp;&nbsp;<span>课程排期&nbsp;-&nbsp;家庭作业</span></h2>
            </div>
          </div>
          
          <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative; margin-top:20px;" >
            <ul class="nav nav-pills x-breadcrumb-nav">
                <li class="pull-left"><a href="${ctx.host}/individual-rounds/${roundId}?status=${status}">基本信息</a></li>
                <li class="pull-left"><a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/weekly-plan/1?status=${status}">周计划</a></li>
                <li class="pull-left ${type == 'weekly' ? 'active' : ''}"><a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/1?type=weekly&status=${status}">家庭作业</a></li>
                <li class="pull-left ${type == 'course' ? 'active' : ''}"><a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/1?type=course&status=${status}&day=1">上课课件</a></li>
                <c:if test="${status!='prepare'}">
                  <li class="pull-left"><a href="${ctx.host}/individual-rounds/${roundId}/physical-data?status=${status}">身体数据</a></li>
                </c:if>
                <li class="pull-left"><a href="${ctx.host}/individual-rounds/${roundId}/basic-information">学员基础信息</a></li>
                <c:if test="${not empty resultReport}">
                <li class="pull-left"><a href="${ctx.host}/individual-rounds/${roundId}/result-report">成果报告</a></li>
                </c:if>
                <div class=" pull-right courseware-btn">
                  <c:if test="${!batchCourseware.editStatus.generated and not currentPrincipal.coursewareMonitor}">
                    <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batchCourseware.id}/link?type=${type}" data-target="#offline-link" data-toggle="modal">发送课件</a>
                  </c:if>
                  <%-- <c:if test="${batchCourseware.editStatus.prepare}">
                    <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batchCourseware.id}/save-all" data-target="#save-all" data-toggle="modal">全部保存</a>
                  </c:if> --%>
                  <c:if test="${not empty batchCourseware.courseRound.student.tagIds and not currentPrincipal.coursewareMonitor}">
                    <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batchCourseware.id}/edit-tags" data-target="#edit-tags" data-toggle="modal">修改标签</a>
                  </c:if>
                </div>
            </ul>
          </div>
          
          <div class="clearfix">
          
          <div class="row" >
          
            <div class="col-xs-2 template-submenu" >
              <ul class="nav nav-pills nav-stacked template-list">
                <c:forEach var="batch" items="${persist.batchCourseware(roundId, type)}">
                  <li class="submenu text-center ${weeks == batch.sorting ? 'active' : ''}"><a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batch.sorting}?type=weekly&status=${courseRound.courseStatus.alias}" >${batch.name}</a></li>
                </c:forEach>
              </ul>
            </div>
          
            <div class="col-xs-7">
              <div class="schedule-action-layout">
                <c:forEach var="daily" items="${persist.dailyCourseware(roundId, weeks, type)}">
                  <div class="action-module">
                    <label class="text-right">${daily.name}:</label>
                    <c:set var="coursewares" value="${persist.courseware(daily.id)}"/>
                    <c:choose>
                      <c:when test="${empty daily.type or (not daily.type.rest and empty coursewares)}">
                        <div class="compile-action text-center">
                          <c:if test="${not currentPrincipal.coursewareMonitor}">
                            <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${weeks}/daily-coursewares/${daily.id}/coursewares/create?coursewareType=weekly" class="btn btn-default btn-shadow-default" data-toggle="modal" data-target="#create">添加动作</a>
                            <c:if test="${type == 'weekly'}">
                              <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${weeks}/daily-coursewares/${daily.id}/rest" class="btn btn-rest btn-success btn-shadow-default" data-toggle="modal" data-target="#rest">设为休息日</a>
                            </c:if>
                          </c:if>
                        </div>
                      </c:when>
                      <c:when test="${daily.type.rest and empty coursewares}">
                        <div class="compile-action">
                          <p class="rest text-center">今日休息
                            <c:if test="${not currentPrincipal.coursewareMonitor}">
                              <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${weeks}/daily-coursewares/${daily.id}/coursewares/create?coursewareType=weekly" class="" data-toggle="modal" data-target="#create">重新添加动作</a>
                            </c:if>
                          </p>
                        </div>
                      </c:when>
                      <c:otherwise>
                        <div class="compile-action clearfix">
                          <c:forEach var="type" items="${enums['coursewareMovementType']}">
                            <div class="row">
                              <label class="text-left">${type.description}：</label>
                              <div class="action-item">
                                <c:forEach var="courseware" items="${coursewares[type.alias]}">
                                  <div class="action-layout">
                                    <c:if test="${not currentPrincipal.coursewareMonitor}">
                                      <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${weeks}/daily-coursewares/${daily.id}/coursewares/${courseware.id}/edit" class="add-action" data-toggle="modal" data-target="#edit">
                                    </c:if>
                                      <div class="action-cover">
                                        <img src="${cloud.prod}/${courseware.movement.cover}-0.6" alt="">
                                        <p>${courseware.movement.name}</p>
                                      </div>
                                      <p>
                                        <c:if test="${courseware.groupAmount != 0}">${courseware.groupAmount}组&nbsp;&nbsp;</c:if>
                                        <c:if test="${courseware.movementNumber != 0}">每组${courseware.movementNumber}次&nbsp;&nbsp;</c:if>
                                        <c:if test="${not empty courseware.maxWeight}">最大重量：${courseware.maxWeight}KG&nbsp;&nbsp;</c:if>
                                        <c:if test="${not empty courseware.time}">计时${courseware.time}秒</c:if>
                                      </p>
                                    <c:if test="${not currentPrincipal.coursewareMonitor}">
                                      </a>
                                      <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${weeks}/daily-coursewares/${daily.id}/coursewares/${courseware.id}/delete" class="close-module" data-toggle="modal" data-target="#delete"></a>
                                    </c:if>
                                  </div>
                                </c:forEach>
                                <c:if test="${not currentPrincipal.coursewareMonitor}">
                                  <div class="action-layout">
                                    <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${weeks}/daily-coursewares/${daily.id}/coursewares/create?type=${type.alias}&coursewareType=weekly" class="add-module" data-toggle="modal" data-target="#create">
                                      <div class="action-add">
                                        <img src="${ctx.resource}/images/add.png" alt="">
                                      </div>
                                    </a>
                                  </div>
                                </c:if>
                              </div>
                            </div>
                          </c:forEach>
                          <c:if test="${not currentPrincipal.coursewareMonitor}">
                            <div class="compile-action text-center">
                              <a href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${weeks}/daily-coursewares/${daily.id}/rest" class="btn btn-rest btn-success btn-shadow-default" data-toggle="modal" data-target="#rest">设为休息日</a>
                            </div>
                          </c:if>
                        </div>
                      </c:otherwise>
                    </c:choose>
                  </div>
                </c:forEach>
              
              </div>
            </div>
            <div class="col-xs-3">
              <c:if test="${type == 'weekly'}">
                 <div class="diet-layout" style="margin-left:25px;">
                   <div class="row">
                     <label>饮食计划:</label>
                   </div>
                   <div class="row" style="margin-right:10px;">
                     <p>早餐：&nbsp;&nbsp;${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].name}
                       <c:if test="${empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]] and not currentPrincipal.coursewareMonitor}">
                         <a class="pull-right" href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batchCourseware.id}/diet?dietType=breakfast" data-toggle="modal" data-target="#diet">添加</a>
                       </c:if>
                     </p>
                     <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]]}">
                       <p>描述：&nbsp;&nbsp;<textarea rows="3"  name="breakfastDescription">${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].description}</textarea></p>
                     </c:if>
                   </div>
                   <div class="row" style="margin-right:10px;">
                     <p>午餐：&nbsp;&nbsp;${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].name}
                       <c:if test="${empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]] and not currentPrincipal.coursewareMonitor}">
                         <a class="pull-right" href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batchCourseware.id}/diet?dietType=lunch" data-toggle="modal" data-target="#diet">添加</a>
                       </c:if>
                     </p>
                     <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]]}">
                       <p>描述：&nbsp;&nbsp;<textarea rows="3"  name="lunchDescription"}>${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].description}</textarea></p>
                     </c:if>
                   </div>
                   <div class="row" style="margin-right:10px;">
                     <p>晚餐：&nbsp;&nbsp;${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].name}
                       <c:if test="${empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]] and not currentPrincipal.coursewareMonitor}">
                         <a class="pull-right" href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batchCourseware.id}/diet?dietType=dinner" data-toggle="modal" data-target="#diet">添加</a>
                       </c:if>
                     </p>
                     <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]]}">
                       <p>描述：&nbsp;&nbsp;<textarea rows="3"  name="dinnerDescription"}>${batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].description}</textarea></p>
                     </c:if>
                   </div>
                   <div class="row" style="margin-right:10px;">
                     <p>早餐加餐：&nbsp;&nbsp;${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks).name : ''}
                       <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]] and empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks and not currentPrincipal.coursewareMonitor}">
                         <a class="pull-right" href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batchCourseware.id}/snacks?snacksType=breakfast" data-toggle="modal" data-target="#diet">添加</a>
                       </c:if>
                     </p>
                     <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks}">
                       <p>描述：&nbsp;&nbsp;<textarea rows="3"  name="breakfastSnacksDescription"}>${persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]].snacks).description}</textarea></p>
                     </c:if>
                   </div>
                   <div class="row" style="margin-right:10px;">
                     <p>午餐加餐：&nbsp;&nbsp;${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks).name : ''}
                       <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]] and empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks and not currentPrincipal.coursewareMonitor}">
                         <a class="pull-right" href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batchCourseware.id}/snacks?snacksType=lunch" data-toggle="modal" data-target="#diet">添加</a>
                       </c:if>
                     </p>
                     <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks}">
                       <p>描述：&nbsp;&nbsp;<textarea rows="3"  name="lunchSnacksDescription"}>${persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]].snacks).description}</textarea></p>
                     </c:if>
                   </div>
                   <div class="row" style="margin-right:10px;">
                     <p>晚餐加餐：&nbsp;&nbsp;${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks ? persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks).name : ''}
                       <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]] and empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks and not currentPrincipal.coursewareMonitor}">
                         <a class="pull-right" href="${ctx.host}/individual-rounds/${roundId}/batch-coursewares/${batchCourseware.id}/snacks?snacksType=dinner" data-toggle="modal" data-target="#diet">添加</a>
                       </c:if>
                     </p>
                     <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks}">
                       <p>描述：&nbsp;&nbsp;<textarea rows="3"  name="dinnerSnacksDescription">${persist.dietaryProgram(batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]].snacks).description}</textarea></p>
                     </c:if>
                   </div>
                   <c:if test="${not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][0]] and not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][1]] and not empty batchCourseware.dietaryPrograms[enums['dietaryProgramType'][2]] and not currentPrincipal.coursewareMonitor}">
                     <div class="row text-center">
                       <a class="btn btn-success btn-shadow btn-shadow-success btn-save" style="display:inline-block; margin:15px;">保存</a>
                     </div>
                   </c:if>
                </div>
              </c:if>
                
              <div class="diet-layout" style="margin-left:25px;">
                <label>Tips:</label>
                <p>${batchCourseware.coachTips}</p>
              </div>
                
            </div>
            
          </div>
          </div>
          
        </div>
          
        </div>

      </div>

    </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/course/batch-courseware.js">
    <script type="text/javascript">
      require(['page/course/batch-courseware'], function(page) {
        page.init({
            "roundId": "${roundId}",
            "roundCode": "${roundCode}",
            "batchId": "${batchCourseware.id}",
            "type": 'individual'
        })
      })
    </script>
  </d:resource>
  
</body>

</html>
